/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/*
 * listaPagosPendientesBanco.java
 *
 * Created on Jan 7, 2012, 9:29:26 AM
 */

package INTERFAZ;

import CONTROLES.ControlCuenta;
import CONTROLES.ControlPago;
import CONTROLES.ControlSucursal;
import CONTROLES.ControlTipoCambio;
import MODELOS.Cliente;
import MODELOS.Cuenta;
import MODELOS.ListaPagos;
import MODELOS.Pago;
import MODELOS.Sucursal;
import MODELOS.TipoCambio;
import Reportes.Reporte;
import UTILITARIOS.Fecha;
import UTILITARIOS.Herramienta;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import UTILITARIOS.MiModelo;
import UTILITARIOS.StringToDate;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Calendar;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author VICENTE
 */
public class listaPagosPendientesBanco extends javax.swing.JDialog {
    /** Creates new form listaPagosPendientesBanco */
    public listaPagosPendientesBanco(javax.swing.JFrame parent, boolean modal){
        super(parent, modal);
        initComponents();
        iniciarComponentes();
        addEventos();
    }

    private void iniciarComponentes(){
        if(Bienvenida.user.getPermiso())
            jButton2.setVisible(true);
        else
            jButton2.setVisible(false);
        tipoCambio = new ControlTipoCambio().dameCambio();

        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, -7);
        java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("dd-MM-yyyy");
        String fecha = sdf.format(c.getTime());
        panelPickFechas2.setDate(fecha);
        fechaI = new Fecha();
        fechaI.setFecha(new StringToDate().convertir(panelPickFechas2.getDateText()));

        fechaF = new Fecha();
        fechaF.setFecha(new StringToDate().convertir(panelPickFechas1.getDateText()));
        sucursal = Bienvenida.sucursal;

        jLabel6.setText(String.valueOf(tipoCambio.getTipoCompra()));
        jLabel7.setVisible(false);
        jLabel8.setVisible(false);
        jLabel3.setText("SUCURSAL: "+sucursal.getNombreSuc());
        jLabel2.setText("DEL: "+fechaI.getFechaPrincipal()+" AL "+fechaF.getFechaPrincipal());        

        String sucursales[] = new ControlSucursal().nombresSuc();
        for(int i = 0; i<sucursales.length; i++)
           choice1.add(sucursales[i]);

        choice1.select(sucursal.getIdSucursal()+"-"+sucursal.getNombreSuc());

        if(Bienvenida.user.getTipoUsuario().equalsIgnoreCase("ADMINISTRADOR") && Bienvenida.user.getToken().equalsIgnoreCase("INGRESAR") ){
           choice1.setEnabled(true);
           }else{
           choice1.setEnabled(false);
           }

        listPagos = new ControlPago().getPagosDisponiblesBanco(sucursal.getIdSucursal(), fechaI.getFechaDate(), fechaF.getFechaDate());
        cargarTabla();
    }
    
    private void addEventos(){
        
        final javax.swing.JDialog yo = this;

        jButton4.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                fechaI.setFecha(new StringToDate().convertir(panelPickFechas2.getDateText()));
                fechaF.setFecha(new StringToDate().convertir(panelPickFechas1.getDateText()));

                StringTokenizer s = new StringTokenizer(choice1.getSelectedItem(),"-");
                int idSucursal = Integer.parseInt(s.nextToken());

                jLabel2.setText("DEL: "+fechaI.getFechaPrincipal()+" AL "+fechaF.getFechaPrincipal());
                jLabel3.setText("SUCURSAL: "+sucursal.getNombreSuc());
                listPagos = new ControlPago().getPagosDisponiblesBanco(idSucursal, fechaI.getFechaDate(), fechaF.getFechaDate());
                cargarTabla();
            }
        });

        pagos.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent e)
            {
                if(pagos.getSelectedRow()>= 0)
                        jButton3.setEnabled(true);                                                            
            }
        });
        jButton3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
//                int idPago = ((Integer) pagos.getValueAt(pagos.getSelectedRow(), 0)).intValue();
                Cuenta cuentaA = new Cuenta();
                cuentaA = new ControlCuenta().getCuenta(listPagos.get(pagos.getSelectedRow()).getPago().getIdCuenta());

                if((cuentaA.getPagos().size() - cuentaA.getPagosPagados().size()- cuentaA.getPagosDisponibles().size())==0){
                    int res = JOptionPane.showConfirmDialog(null, "Se pagaran los ultimos Intereses pendientes de esta cuenta\n Con lo que se procedera a Cerrar la Cuenta", "Advertencia", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
                    if(res ==0){
                        System.out.println("entro00");
                        GenerarReciboCancelarCuenta nuevoRecibo = new GenerarReciboCancelarCuenta(yo, true, cuentaA, "CERRADA", "DEPOSITO BANCARIO");
                        Herramienta.centerOnScreen(nuevoRecibo);
                        nuevoRecibo.setVisible(true);
                    }
                }else{
                    GenerarReciboPagoCuenta nuevoRecibo = new GenerarReciboPagoCuenta(yo,true, cuentaA, "DEPOSITO BANCARIO");
                    Herramienta.centerOnScreen(nuevoRecibo);
                    nuevoRecibo.setVisible(true);
                }
            }
        });
        jButton2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                dispose();
                Reporte r = new Reporte();
                r.ejecutarListaPagosXBanco(sucursal.getIdSucursal(),fechaI.getFechaDate(), fechaF.getFechaDate());
            }
        });
        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        pagos = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        choice1 = new java.awt.Choice();
        jLabel10 = new javax.swing.JLabel();
        panelPickFechas1 = new UTILITARIOS.PanelPickFechas();
        panelPickFechas2 = new UTILITARIOS.PanelPickFechas();
        jButton4 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "LISTA DE PAGOS", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 14))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        pagos.setName("pagos"); // NOI18N
        jScrollPane1.setViewportView(pagos);

        jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 11));
        jLabel4.setText("NOTA: Para realizar un PAGO especifico seleccionelo de la tabla y luego presione el boton =>");
        jLabel4.setName("jLabel4"); // NOI18N

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton3.setText("PAGAR INTERES");
        jButton3.setEnabled(false);
        jButton3.setName("jButton3"); // NOI18N

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("TOTAL  TABLE");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel8.setText("|");
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("tot");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel14.setText("TOTALES en BS:");
        jLabel14.setName("jLabel14"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1225, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(30, 30, 30)
                        .addComponent(jButton3))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel14))
                .addContainerGap())
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("LISTA DE PAGOS DE INTERES PENDIENTES PARA DEPOSITAR POR BANCO");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("fecha");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("sucursal");
        jLabel3.setName("jLabel3"); // NOI18N

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton1.setText("SALIR");
        jButton1.setName("jButton1"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1))
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1247, Short.MAX_VALUE)
            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1247, Short.MAX_VALUE)
            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1247, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addGap(16, 16, 16)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Criterios de busqueda"));
        jPanel3.setName("jPanel3"); // NOI18N

        choice1.setName("choice1"); // NOI18N

        jLabel10.setFont(new java.awt.Font("Times New Roman", 0, 12));
        jLabel10.setText("Elegir Sucursal");
        jLabel10.setName("jLabel10"); // NOI18N

        panelPickFechas1.setName("panelPickFechas1"); // NOI18N

        panelPickFechas2.setName("panelPickFechas2"); // NOI18N

        jButton4.setText("Listar");
        jButton4.setName("jButton4"); // NOI18N

        jLabel11.setFont(new java.awt.Font("Times New Roman", 0, 12));
        jLabel11.setText("Inicio");
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setFont(new java.awt.Font("Times New Roman", 0, 12));
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("Fin");
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(panelPickFechas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(panelPickFechas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(choice1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(55, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton4))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(choice1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelPickFechas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(panelPickFechas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("T.C. COMPRA:");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("jLabel6");
        jLabel6.setName("jLabel6"); // NOI18N

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton2.setText("IMPRIMIR LISTA");
        jButton2.setName("jButton2"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(387, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(181, 181, 181)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6))
                    .addComponent(jButton2))
                .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton2))
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    /**
    * @param args the command line arguments
    */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Choice choice1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable pagos;
    private UTILITARIOS.PanelPickFechas panelPickFechas1;
    private UTILITARIOS.PanelPickFechas panelPickFechas2;
    // End of variables declaration//GEN-END:variables
    private MiModelo modelo_pagos;

    ArrayList<ListaPagos> listPagos;
    private TipoCambio tipoCambio;
    private Fecha fechaI;
    private Fecha fechaF;
    private Sucursal sucursal;

    private void cargarTabla() {
        if(Bienvenida.user.getPermiso()== true)
            modelo_pagos = new MiModelo(new Object [][] {},new String [] {"ID","N# CUENTA NFN","Inversion", "N# Pago", "Fecha", "Nombre del Cliente", "Banco", "Cuenta Banco", "Monto Sus", "Monto Bs", "Monto Real Bs"}, -1);
        else
            modelo_pagos = new MiModelo(new Object [][] {},new String [] {"ID","N# CUENTA NFN","Inversion", "N# Pago", "Fecha", "Nombre del Cliente", "Banco", "Cuenta Banco", "Monto Sus", "Monto Bs"}, -1);
        ListaPagos l;
        Pago p;
        Cuenta cu;
        Cliente cli;
        double total = 0;
        double totalBs = 0;
        StringToDate st = new StringToDate();
        if(listPagos.size()>0){
            for(int i=0;i<listPagos.size();i++){
                l = listPagos.get(i);
                p = l.getPago();
                cu = l.getCuenta();
                cli = l.getCliente();
                if(Bienvenida.user.getPermiso()== true){
                    double real = Herramienta.redondear((cu.getMonto()*(cu.getCodigoCuenta()/100)*l.getPlan().getFrecuenciaPago())* tipoCambio.getTipoCompra(),2);
                    Object [] auxPago = {
                        p.getIdPago(),
                        cu.getNumeroCuenta(),
                        Herramienta.redondearDoubleString(cu.getMonto()),
                        p.getNumeroPago(),
                        st.dateAstring(p.getFechaPago()),
                        cli.getNombreCompletoCliente(),
                        cli.getBanco(),
                        cli.getCuenta(),
                        Herramienta.redondearDoubleString(p.getMonto()),
                        Herramienta.redondearDoubleString(p.getMonto()*tipoCambio.getTipoCompra()),
                        Herramienta.redondearDoubleString(real)
                    };
                    total = total+Herramienta.redondear(p.getMonto()*tipoCambio.getTipoCompra(),2);
                    totalBs = totalBs+Herramienta.redondear(real,2);
                    modelo_pagos.addRow(auxPago);
                }else{
                    Object [] auxPago = {
                        p.getIdPago(),
                        cu.getNumeroCuenta(),
                        Herramienta.redondearDoubleString(cu.getMonto()),
                        p.getNumeroPago(),
                        p.getFechaPago(),
                        cli.getNombreCompletoCliente(),
                        cli.getBanco(),
                        cli.getCuenta(),
                        Herramienta.redondearDoubleString(p.getMonto()),
                        Herramienta.redondearDoubleString(p.getMonto()*tipoCambio.getTipoCompra())
                    };
                    total = total+Herramienta.redondear(p.getMonto()*tipoCambio.getTipoCompra(),2);
                    modelo_pagos.addRow(auxPago);
                }
            }
        }
        jLabel9.setText(Herramienta.redondearDoubleString(total));        
        pagos.setModel(modelo_pagos);
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();
        tcr.setHorizontalAlignment(SwingConstants.RIGHT);

        DefaultTableCellRenderer tcrc = new DefaultTableCellRenderer();
        tcrc.setHorizontalAlignment(SwingConstants.CENTER);

        pagos.getColumnModel().getColumn(0).setMaxWidth(100);
        pagos.getColumnModel().getColumn(0).setMinWidth(100);
        pagos.getColumnModel().getColumn(0).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(1).setMaxWidth(100);
        pagos.getColumnModel().getColumn(1).setMinWidth(100);
        pagos.getColumnModel().getColumn(1).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(2).setMaxWidth(100);
        pagos.getColumnModel().getColumn(2).setMinWidth(100);
        pagos.getColumnModel().getColumn(2).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(3).setMaxWidth(80);
        pagos.getColumnModel().getColumn(3).setCellRenderer(tcrc);
        pagos.getColumnModel().getColumn(4).setCellRenderer(tcrc);
        pagos.getColumnModel().getColumn(4).setMaxWidth(80);
        pagos.getColumnModel().getColumn(5).setCellRenderer(tcrc);
        pagos.getColumnModel().getColumn(6).setMaxWidth(140);
        pagos.getColumnModel().getColumn(6).setMinWidth(140);
        pagos.getColumnModel().getColumn(6).setCellRenderer(tcrc);
        pagos.getColumnModel().getColumn(7).setMaxWidth(120);
        pagos.getColumnModel().getColumn(7).setMinWidth(120);
        pagos.getColumnModel().getColumn(7).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(8).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(8).setMaxWidth(90);
        pagos.getColumnModel().getColumn(9).setCellRenderer(tcr);
        pagos.getColumnModel().getColumn(9).setMaxWidth(100);
        if(Bienvenida.user.getPermiso()){
            pagos.getColumnModel().getColumn(10).setMaxWidth(110);
            pagos.getColumnModel().getColumn(10).setMinWidth(110);
            pagos.getColumnModel().getColumn(10).setCellRenderer(tcr);
            jLabel7.setVisible(true);
            jLabel8.setVisible(true);
            jLabel7.setText(Herramienta.redondearDoubleString(totalBs));
       }
    }
}
